/**
 * Copyright (c) 2018 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package io.renren;

import io.renren.common.interceptor.MyLoginInterceptor;
import io.renren.common.interceptor.WeixinInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
public class AdminApplication extends SpringBootServletInitializer implements WebMvcConfigurer {

	@Autowired
	private WeixinInterceptor weixinInterceptor;
	@Autowired
	private MyLoginInterceptor myLoginInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {

//		registry.addInterceptor(weixinInterceptor).addPathPatterns("/h5/**")
//				.excludePathPatterns("**/login**");

		/*registry.addInterceptor(myLoginInterceptor)
				.addPathPatterns("/h5/**")
				.excludePathPatterns("/h5/login")
				.excludePathPatterns("/h5/reg")
				.excludePathPatterns("/h5/cer-login")
				.excludePathPatterns("/h5/cer-detail")
				.excludePathPatterns("/h5/exam-list")
				.excludePathPatterns("/h5/about")
				.excludePathPatterns("/h5/expert-list")
				.excludePathPatterns("/h5/expert")
				.excludePathPatterns("/h5/sky-boy-login")
				.excludePathPatterns("/h5/sky-boy")
		;*/
	}


	public static void main(String[] args) {
		SpringApplication.run(AdminApplication.class, args);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(AdminApplication.class);
	}
}